package lab03.test03;

import java.io.*;

public class Test03 {

    public static void main(String[] args) {

        String path="d:\\test.txt";
        File file=new File(path);

        FileOutputStream fileOutputStream=null;
        FileInputStream fileInputStream=null;
        FileWriter fileWriter  = null;


        try {
            fileOutputStream=new FileOutputStream(file);
            fileInputStream = new FileInputStream(path);
            fileOutputStream.write(new String("Beijing欢迎你！").getBytes());
            byte[] data = new byte[100];


            while ((fileInputStream.read(data)) != -1){
                String keyword;
                keyword = new String(data,"GBK");
                System.out.println(keyword);
            }

           fileWriter = new FileWriter(path,true);
            fileWriter.write("我的学号：100000");

        } catch (FileNotFoundException e) {

            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                fileOutputStream.close();
                fileInputStream.close();
                fileWriter.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}
